﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IFRS.Web;
using System.Data;
using IFRS.DataAccess.DAL;
using IFRS.Models;
using IFRS_Global;

public partial class IFRS_WIN29_3V : PageBase
{
    #region "---------- Property -----------"

    private readonly SPR_DOUBTFUL dal_doubtful = new SPR_DOUBTFUL();
    private Doubtful doubtful = new Doubtful();

    #endregion

    #region "---------- Events -----------"

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Page.IsPostBack || Page.IsCallback))
        {
            this.ViewMenu();
            BindControlData();
            BindData();
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }

    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN29_1S.aspx");
    }

    #endregion

    #region "----- Methods -------"

    private void ViewMenu()
    {
        this.MenuTitleBar = Resources.ifrsResource.View + Resources.ifrsMenu.WIN04;
    }

    private void BindControlData()
    {
        SetControlReadOnly(form_control);
    }

    private void BindData()
    {
        int ID = Convert.ToInt32(Request.QueryString["id"].ToString());
        DataTable dtDOUBTFUL = dal_doubtful.SEARCH_BYID(ID);
        List<Doubtful> DOUBTFULList = new List<Doubtful>();
        ConvertHelper.ConvertDataTableToObject(dtDOUBTFUL, DOUBTFULList);
        if (dtDOUBTFUL.Rows.Count > 0)
        {
            txtTransactionDate.Text = DOUBTFULList[0].TransactionDate.DateToString();
            txtPass.Text = DOUBTFULList[0].Pass.ToString();
            txtSpecialMention.Text = DOUBTFULList[0].SpecialMention.ToString();
            txtSubstandard.Text = DOUBTFULList[0].Substandard.ToString();
            txtDoubtfulValue.Text = DOUBTFULList[0].DoubtfulValue.ToString();
            txtDoubtfulLoss.Text = DOUBTFULList[0].DoubtfulLoss.ToString();
        }
    }

    #endregion
}